package com.lhl.student.service;
import javax.servlet.http.HttpServletRequest;

/**
 * ҵ������ʵ����
 */
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lhl.student.bean.StudentBean;
import com.lhl.student.mapper.StudentMapper;


/**
 * 
 *StudentServiceImpl
 * @author liaohonglai
 * 2017年5月15日   上午1:17:52
 */
@Service
public class StudentServiceImpl implements StudentService {
	@Autowired
	private StudentMapper studentMapper;
	//登陆
	public boolean login(HttpServletRequest request) {
		String stuId =request.getParameter("studentId");
		String stuName =MD5Util.MD5String(stuId+""+request.getParameter("studentName"));
		StudentBean stubean = new StudentBean();
		stubean.setStuId(stuId);
		stubean.setStuName(stuName);
		int flag=studentMapper.login(stubean);
		if(flag>0){
			return true;
		}else{
			return false;
		}
	}
	//注册
	public boolean register(HttpServletRequest registerRequest) {
		String stuId =registerRequest.getParameter("studentName");
		String stuName =MD5Util.MD5String(stuId+""+registerRequest.getParameter("passWord"));
		StudentBean stubean = new StudentBean();
		stubean.setStuId(stuId);
		stubean.setStuName(stuName);
		int flag = studentMapper.register(stubean);
		if(flag>0){
			return true;
		}else{
			return false;
		}
	}

}
